home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Development Tools & Languages / MouseInfo / About.cp next >
Encoding:
Text File  |  1995-02-04  |  3.2 KB  |  112 lines  |  [TEXT/MPS ]

  1. //     About.cp
  2. //     Copyright © 1992 by Apple Computer, Inc. All rights reserved.
  3. //    Kent Sandvik DTS
  4. //    This file contains the About box code including any adorners/behaviors
  5. //    The resources are placed in the project .r file
  6. //    Version Info (latest first):
  7. //
  8. //    <1>        khs        1.0        First final version
  9. //    <2>        khs        1.0.1    Fixed a memory leak in TMapApplication::GetSleepValue()
  10.  
  11.  
  12. #ifndef __ABOUT__
  13. #include "About.h"
  14. #endif
  15.  
  16.  
  17. //    Functions
  18.  
  19. #pragma segment ARes
  20. void CreateAboutBox()
  21. {
  22.     TWindow * aboutBoxWindow;
  23.     CStr255 programName,  versionInfo, finalProduct;
  24.  
  25.     //    Yes, I do know this is a waste of resources to 'macroDontDeadStrip' and
  26.     //    register the adorner type every time we open the About box. However, for the
  27.     //    sake of modularity, where I only need to place a CreateAboutBox() statement
  28.     //    inside the TApplication->DoAboutBox(), it made sense - instead of writing all
  29.     //    kinds of init methods that need to be called from IApplication.
  30.  
  31.     // so the linker doesn't dead strip class info 
  32.     macroDontDeadStrip(TMetalBlueFill);
  33.  
  34.     RegisterStdType("TMetalBlueFill", kBlueMetalLook);// register adorner types
  35.  
  36.     //    Get application name    
  37.     gApplication->GetApplicationName(programName);
  38.  
  39.     //    Get version information
  40.     VersRecHndl versInfo = (VersRecHndl)GetResource(kVersInfoType, kVers1InfoID);
  41.     if (versInfo)                                // short one?
  42.         versionInfo = (**versInfo).shortVersion;// get version info from version 1
  43.     else
  44.         versionInfo = " ";                        // nooooothing
  45.  
  46.  
  47.     //    Create Window
  48.     aboutBoxWindow = gViewServer->NewTemplateWindow(phAboutBox, NULL);
  49.     FailNIL(aboutBoxWindow);
  50.  
  51.     //    Hook in any adorners
  52.     aboutBoxWindow->AddAdorner(NewStdAdorner('blmt', "", 'blmt', kFreeOnDeletion), kAdornBefore, kRedraw);
  53.  
  54.     // Stuff in the version info to the other status view, but first get a ptr to it...
  55.     TStaticText * versionField = (TStaticText *)aboutBoxWindow->FindSubView('sta2');
  56.     finalProduct = programName + CStr255(" ") + versionInfo;
  57.     versionField->SetText(finalProduct, TRUE);
  58.  
  59.     //    Open the About box window, and let the user close it whenever...
  60.     aboutBoxWindow->Open();
  61. }
  62.  
  63.  
  64. //--------------------------------------------------------------------------------------------------
  65. //    About Box color adorner
  66. //--------------------------------------------------------------------------------------------------
  67. CRGBColor gMetalBlue(26312,
  68.                      14340,
  69.                      47359);                    // Setup the metal-blue color
  70.  
  71.  
  72. //    Empty constructor - for avoiding ptabs in global data space
  73. #pragma segment ARes
  74.  
  75. #undef Inherited
  76. #define Inherited TAdorner
  77. DefineClass(TMetalBlueFill, Inherited);
  78.  
  79. TMetalBlueFill::TMetalBlueFill()
  80. {
  81. }
  82.  
  83.  
  84. //    Draw TGrayFill Adorner method
  85.  
  86. #pragma segment ARes
  87.      void TMetalBlueFill::Draw(TView* itsView,
  88.                                  const VRect&    /*area*/)
  89. {
  90.     CRGBColor saveColor;
  91.     PenState savePenState;
  92.     VRect adornArea;
  93.     CRect QDArea;
  94.     CRect tempRect;
  95.  
  96.     GetPenState(&savePenState);                    // save off the current pen state 
  97.     GetIfColor(saveColor);                        // and the foreground color
  98.     PenNormal();
  99.  
  100.     itsView->GetAdornExtent(adornArea);            // get area
  101.     itsView->ViewToQDRect(adornArea, QDArea);
  102.     tempRect = QDArea;
  103.  
  104.     SetIfColor(gMetalBlue);                        // colorize it
  105.     PaintRect(tempRect);
  106.  
  107.     SetIfColor(saveColor);                        // restore the foreground color and the pen
  108.     SetPenState(&savePenState);
  109. }
  110.  
  111.  
  112.